package com.ktgj.flight.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.flight.domain.FlightOrderCashInfo;
import com.ktgj.flight.service.IFlightOrderCashInfoService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 订单支付信息Controller
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@ControllerAdvice
@RestController
@RequestMapping("/info")
public class FlightOrderCashInfoController extends BaseController
{
    @Autowired
    private IFlightOrderCashInfoService flightOrderCashInfoService;

    /**
     * 查询订单支付信息列表
     */
    @PreAuthorize(hasPermi = "flight:info:list")
    @GetMapping("/list")
    public TableDataInfo list(FlightOrderCashInfo flightOrderCashInfo)
    {
        startPage();
        List<FlightOrderCashInfo> list = flightOrderCashInfoService.selectFlightOrderCashInfoList(flightOrderCashInfo);
        return getDataTable(list);
    }

    /**
     * 导出订单支付信息列表
     */
    @PreAuthorize(hasPermi = "flight:info:export")
    @Log(title = "订单支付信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlightOrderCashInfo flightOrderCashInfo) throws IOException
    {
        List<FlightOrderCashInfo> list = flightOrderCashInfoService.selectFlightOrderCashInfoList(flightOrderCashInfo);
        ExcelUtil<FlightOrderCashInfo> util = new ExcelUtil<FlightOrderCashInfo>(FlightOrderCashInfo.class);
        util.exportExcel(response, list, "订单支付信息数据");
    }

    /**
     * 获取订单支付信息详细信息
     */
    @PreAuthorize(hasPermi = "flight:info:query")
    @GetMapping(value = "/{cashinfoId}")
    public AjaxResult getInfo(@PathVariable("cashinfoId") Long cashinfoId)
    {
        return AjaxResult.success(flightOrderCashInfoService.selectFlightOrderCashInfoById(cashinfoId));
    }

    /**
     * 新增订单支付信息
     */
    @PreAuthorize(hasPermi = "flight:info:add")
    @Log(title = "订单支付信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlightOrderCashInfo flightOrderCashInfo)
    {
        return toAjax(flightOrderCashInfoService.insertFlightOrderCashInfo(flightOrderCashInfo));
    }

    /**
     * 修改订单支付信息
     */
    @PreAuthorize(hasPermi = "flight:info:edit")
    @Log(title = "订单支付信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlightOrderCashInfo flightOrderCashInfo)
    {
        return toAjax(flightOrderCashInfoService.updateFlightOrderCashInfo(flightOrderCashInfo));
    }

    /**
     * 删除订单支付信息
     */
    @PreAuthorize(hasPermi = "flight:info:remove")
    @Log(title = "订单支付信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cashinfoIds}")
    public AjaxResult remove(@PathVariable Long[] cashinfoIds)
    {
        return toAjax(flightOrderCashInfoService.deleteFlightOrderCashInfoByIds(cashinfoIds));
    }
}
